bitkeeper revision 1.962 (40cd9f1f2QxKhNFa2ms5ieF5zvkihQ)
authoriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Mon, 14 Jun 2004 12:50:39 +0000 (12:50 +0000)
committeriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Mon, 14 Jun 2004 12:50:39 +0000 (12:50 +0000)
backwards compatibility with exisiting config files : xenctl.utils -> xenctl.ip
fix readlines breakage
temporailly disable vdisk support to avoid sqlite depnedancy

tools/examples/xm_dom_create.py
tools/xenctl/lib/ip.py
tools/xenctl/lib/utils.py
tools/xenmgr/lib/server/SrvVdiskDir.py

index ce89426f9d7c6e3a86667a53fa08cda388d7f97f..c7cd8d67019ef012535327577fdaddc3e52a01dc 100755 (executable)
@@ -9,7 +9,8 @@ import socket
 import getopt
 import signal
 import syslog
-
+import xenctl.ip
+import xenctl.utils
 import xenctl.console_client
 
 from xenmgr import sxp
index 0f7f61e3f8baa447d7aa7126acb992199e24fb2c..bf5a6a2dff656295b4703d24bd3fa8508615b4c0 100644 (file)
@@ -10,7 +10,7 @@ def get_current_ipaddr(dev='eth0'):
     network interface (default 'eth0').
     """
     fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
-    lines = readlines(fd)
+    lines = fd.readlines()
     for line in lines:
         m = re.search( '^\s+inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
                        line )
@@ -23,7 +23,7 @@ def get_current_ipmask(dev='eth0'):
     network interface (default 'eth0').
     """
     fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
-    lines = readlines(fd)
+    lines = fd.readlines()
     for line in lines:
         m = re.search( '^.+Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
                        line )
@@ -36,7 +36,7 @@ def get_current_ipgw(dev='eth0'):
     network interface (default 'eth0').
     """
     fd = os.popen( '/sbin/route -n' )
-    lines = readlines(fd)
+    lines = fd.readlines()
     for line in lines:
         m = re.search( '^\S+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' +
                        '\s+\S+\s+\S*G.*' + dev + '.*', line )
index 8391ff590c4e9c145c25306c4a352c54ea2cd581..69bf7793334fae019620aa92dbcd9f33e3648362 100644 (file)
@@ -1,4 +1,4 @@
-import os, re, socket, string, sys, tempfile
+import os, re, socket, string, sys, tempfile, xenctl.ip
 
 ##### Module variables
 
@@ -28,32 +28,22 @@ except ImportError:
 
 ##### Networking-related functions
 
-def get_current_ipgw():
-    """Return a string containing the default IP gateway."""
-    fd = os.popen( '/sbin/route -n' )
-    lines = fd.readlines()
-    for line in lines:
-        m = re.search( '^0.0.0.0+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' +
-                       '\s+0.0.0.0+\s+\S*G.*', line )
-        if m:
-            return m.group(1)
-    return None
-
+def get_current_ipaddr(dev='eth0'):
+    return xenctl.ip.get_current_ipaddr(dev)
+def get_current_ipmask(dev='eth0'):
+    return xenctl.ip.get_current_ipmask(dev)
+def get_current_ipgw(dev='eth0'):
+    return xenctl.ip.get_current_ipgw(dev)
+def setup_vfr_rules_for_vif(dom,vif,addr):
+    return xenctl.ip.setup_vfr_rules_for_vif(dom,vif,addr)
+def inet_aton(addr):
+    return xenctl.ip.inet_aton(addr)
+def inet_ntoa(n):
+    return xenctl.ip.inet_ntoa(n)
+def add_offset_to_ip(addr, offset):
+    return xenctl.ip.add_offset_to_ip(addr, offset)
 def check_subnet( ip, network, netmask ):
-    l = string.split(ip,'.')
-    n_ip = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) | 
-          (string.atoi(l[2])<<8)  | string.atoi(l[3]) ) 
-
-    l = string.split(network,'.')
-    n_net = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) | 
-          (string.atoi(l[2])<<8)  | string.atoi(l[3]) )
-
-    l = string.split(netmask,'.')
-    n_mask = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) | 
-          (string.atoi(l[2])<<8)  | string.atoi(l[3]) )
-    
-    return (n_ip&n_mask)==(n_net&n_mask)
-
+    return xenctl.ip.check_subnet( ip, network, netmask )
 
 ##### VBD-related Functions
 
index a6a9e557825a791d08a63f7183defb422e13ee9c..67d0955259ea65a972ef0996c352d4e0585dc933 100644 (file)
@@ -9,7 +9,7 @@ class SrvVdiskDir(SrvDir):
 
     def __init__(self):
         SrvDir.__init__(self)
-        self.xvdisk = XendVdisk.instance()
+        #self.xvdisk = XendVdisk.instance()
 
     def vdisk(self, x):
         val = None